#include <p30f4013.h>
#include <stdlib.h>
#include "Delays.h"



//--------------------------------------------------------------------------
//		Timing delays
//--------------------------------------------------------------------------


/**********************************************************
	  All of these delays are based on an 8MHz clock
**********************************************************/


void seconds(char num)
{
    tenth_seconds(num*10);
	

	return;
}


/* 
	INPUT: Number from 0 to 255
	OUTPUT: Generates a delay equal to 0.1s * input
*/
void tenth_seconds(char num)
{    
    milliseconds(num*100);

	return;
}



/*
	INPUT: Number from 0 to 255
	OUTPUT: Generates a delay equal to 0.001seconds * num
*/
void milliseconds(int num)
{
	int i;

	while(num--)
	{
		for(i = 0; i<4910; i++);
	}
	

	return;
}


void microseconds(int num)
{
    int i;

    while(num--)
    {
        for(i=0; i<2; i++);        
    }


    return;
}



/*
	INPUT: none
	OUTPUT: Generates a 50uS delay
*/
void delay_50uS()
{
	short i;


	for(i = 0; i<275; i++);


	return;
}

/*
void delay_50uS(void)
{
	char i;
	for(i=0; i<4; i++)
	{
		_asm
			nop
			nop
			nop
			nop
		_endasm

	}

	return;
}
*/